package com.hsgene.consumables.persistence;

import com.hsgene.common.util.result.ApiResult;
import com.hsgene.consumables.condition.GoodsCondition;
import com.hsgene.consumables.domain.ConsumablesInventoryInfo;
import com.hsgene.consumables.dto.ConsumablesInventoryInfoDto;
import com.hsgene.consumables.mapper.BaseMapper;
import com.hsgene.product.domain.GeneticCommodityCategory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 库存管理持久层
 *
 * @author wxf
 * @date 2018/8/15 8:55
 **/
public interface ConsumablesInventoryRepository extends BaseMapper<ConsumablesInventoryInfo> {

    /**
     * 获取耗材库存列表
     *
     * @return
     */
    List<ConsumablesInventoryInfoDto> queryInventoryInfo(@Param("condition")GoodsCondition condition);

    /**
     * 查询是否存在
     * @param id
     * @param unitId
     * @param warningAmount
     * @return
     */
    @Select("select 1 from genetic_goods where id=#{id} and unit_id=#{unitId} " +
            "and warning_amount = #{warningAmount} and delete_flag=0 limit 1")
    Object queryIsExists(@Param("id") String id, @Param("unitId") String unitId, @Param("warningAmount") int warningAmount);

    /**
     * 更新
     *
     * @param inventoryInfo 更新信息
     * @return
     */
    boolean updateInventoryInfo(@Param("inventoryInfo") ConsumablesInventoryInfo inventoryInfo);

    ConsumablesInventoryInfoDto getInventoryDetais(@Param("id") String id);

    void deleteUnitInfoMore(List<ConsumablesInventoryInfo> infosNoused);

    int insertInventory(ConsumablesInventoryInfo inventoryInfo);

    /**
     * 获取数量
     * @param condition
     * @return
     */
    int getCount(@Param("condition") GoodsCondition condition);

    /**
     * 更新耗材
     * @param inventoryInfo
     * @return
     */
    int updateGoodsByPrimaryKeySelective(ConsumablesInventoryInfo inventoryInfo);

    List<ConsumablesInventoryInfoDto> getByIds(String[] split);

    /**
     * 根据名称查找耗材
     * @param name
     * @return
     */
    ConsumablesInventoryInfoDto getByGoodsName(String name);
    /**
     *根据id查找
     * @author FX
     * @date 2018/10/30 10:49
     * @param id
     * @return
     */
    ConsumablesInventoryInfoDto getById(String id);
}
